<?
require("config.php");

$location_status .= " | Edit";

$show_backnav = "features_menu";

$menuname = NULL;

$menutarget = NULL;

if (NULL!=$action){

	$dir = "$table/";

	myUpload($Image,$Image_name,$dir);
	myUpload($Icon,$Icon_name,$dir);


	if ($Image_name == null) $Image_name = $bk_Image;
	if ($Icon_name == null) $Icon_name = $bk_Icon;

	if ($remove_Image=="ture") $Image_name=NULL;
	if ($remove_Icon=="ture") $Icon_name=NULL;


   $field = array(
	"code", 
	"name",
	"description",
	"icon",
	"image", 
	);


   $content = array(
	$Code,
	$Name,
	$Description,
	$Icon_name,
	$Image_name,
	);

   $expression = "id = $id";

   myUpdate($table,$field,$content,$expression);

   header("location:" . $rela_path . "share/msg.php?v=20");

}else{
	$Query = "select * from $table where id = $id";
	$r = myQuery($Query);

	if (!$r)header("location:" . $rela_path . "share/msg.php?v=9002");

	$Code = $r[0][1];
	$Name = $r[0][2];
	$Description = $r[0][3];
	$Image = $r[0][5];
	$Icon = $r[0][4];

}

require($rela_path . "inc/header.php");

?>
<form action="" method="post" enctype="multipart/form-data" name="form1">
<table width="95%" border="0" align="center">
  <tr> 
    <td align="right">&nbsp; </td>
  </tr>
  <tr> 
    <td><p><br>
      </p>
      <table width="75%">
        <tr> 
          <td class="tdheader">Code :</td>
          <td><input type="text" class="text" name="Code" size="40" value=<?print($Code)?>> 
            <br> 
            <!--hidden field-->
            <input name="action" type="hidden" value="edit"> 
			<input name="bk_Image" type="hidden" value="<?print($Image)?>"> 
			<input name="bk_Icon" type="hidden" value="<?print($Icon)?>"> 
          </td>
        </tr>
        <tr> 
          <td class="tdheader">Name :</td>
          <td><input type="text" class="text" name="Name" size="40" value="<?print($Name)?>"></td>
        </tr>
        <tr> 
          <td class="tdheader">Description :</td>
          <td><TEXTAREA NAME="Description" ROWS="6" COLS="50" class="text"><?print($Description)?></TEXTAREA></td>
        </tr>
        <tr> 
          <td class="tdheader">Icon :</td>
          <td><?loadImage($Icon,$rela_path . $PIC_DIR . "$table/")?>
		  <?removeImage($Icon,"remove_Icon")?>
<input name="Icon" type="File" class="text" size="40"></td>
        </tr>

        <tr> 
          <td class="tdheader">Image :</td>
          <td><?loadImage($Image,$rela_path . $PIC_DIR . "$table/")?>
		  <?removeImage($Image,"remove_Image")?>
		  <input name="Image" type="File" class="text" size="40"></td>
        </tr>

        <tr> 
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input type="image" src="../../images/bt_cancel.gif" onClick="Redirect('features_menu.php',1);return false;"> <input type="image" src="../../images/bt_save.gif">
          </td>
        </tr>
      </table>
      <p> <br>
        <br>
        <br>
        <br>
        <br>
        <br>
      </p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp; </p></td>
  </tr>
</table>
<?
require($rela_path . "inc/footer.php");
?>
